<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ $linkCard->title }}</title>
    <meta name="description" content="{{ $linkCard->describe }}">
    <link href="{{ $linkCard->logo }}" rel="shortcut icon" type="image/x-icon">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1, viewport-fit=cover">
    <script src="//file.wailian1.cn/assets/js/v2/jquery-3.5.1-min.js?v=2023070601"></script>
    <link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/2.4.0/weui.min.css?v=202207071010">
</head>
<style>
    html,body{
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
        background-color: #FFFFFF;
    }
    .cotainer {
        width: 100%;
        height: 100%;
        background-color: #FFFFFF;
        float: left;
    }
    .card-iframe {
        display: block;
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        border: none;
        float: left;
    }
</style>
<body>
    <div id="cotainer" class="cotainer">
        
    </div>
    <script type="text/javascript">
        var linkurl = "{{ $linkurl }}";
        $(document).ready(function(){
            status = getUrlParam("status");
            var douyin = isDouyinClient();
            if (!douyin) {
                errorNotice("请使用抖音访问","当前环境异常，请使用抖音访问本链接!");
                return;
            } else {
                if (status == "create") {
                    localStorage.setItem('mini_set',1);
                    var currentUrl = window.location.href;
                    currentUrl = currentUrl.replace('?status=create', '');
                    currentUrl = currentUrl.replace('&status=create', '');
                    window.location.href = currentUrl;
                    return;
                } else {
                    var mini_settimes = localStorage.getItem('mini_set') || 2;
                    if (mini_settimes == 1) {
                        localStorage.setItem('mini_set',3);
                        var device = getDeviceType();
                        if (device == "android") {
                            errorNotice("抖音卡片制作提醒","抖音私信卡片首次必须使用<font color='#FD6666'>苹果手机</font>制作,制作成功后安卓和苹果手机均可分享转发使用。");
                            return;
                        } else {
                            $("#cotainer").html('<img src="https://res.wailian1.cn/uploads/20230824/9089278.jpg" style="width:100%;"/>');
                            return;
                        }
                    } else {
                        loadWebview();
                    }
                }
            }
        });

        function loadWebview() {
            $("#cotainer").html('<iframe class="card-iframe" src="'+linkurl+'"/>');
        }

        function getDeviceType() {
            if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
                return "iphone";
            } else if (/(Android)/i.test(navigator.userAgent)) {
                return "android";
            } else {
                return "pc";
            };
        }

        function isDouyinClient(){
            var ua = window.navigator.userAgent.toLowerCase();
            if(ua.match(/aweme/i) == 'aweme'){
                return true;
            }else{
                return false;
            }
        }

        function errorNotice(title,message) {
            $("#cotainer").html('<div class="page"><div class="weui-msg"><div class="weui-msg__icon-area"><i class="weui-icon-warn weui-icon_msg-primary"></i></div><div class="weui-msg__text-area"><h2 class="weui-msg__title">'+title+'</h2><p class="weui-msg__desc">'+message+'</p></div></div></div>');
        }

        function getUrlParam(paraName) {
            var url = document.location.toString();
            var arrObj = url.split("?");
            if (arrObj.length > 1) {
                var arrPara = arrObj[1].split("&");
                var arr;

                for (var i = 0; i < arrPara.length; i++) {
                    arr = arrPara[i].split("=");

                    if (arr != null && arr[0] == paraName) {
                        return arr[1];
                    }
                }
                return "";
            }
            else {
                return "";
            }
        }
    </script>
</body>

</html>